package com.lydia.service;

/**
 * @author Admin
 */

public enum OracleColumnType {
    VARCHAR("VARCHAR","VARCHAR","VARCHAR"),
    VARCHAR2("VARCHAR2","VARCHAR","VARCHAR"),
    NVARCHAR2("NVARCHAR2","VARCHAR","VARCHAR"),
    INTEGER("INTEGER","INT","INT"),
    NUMBER("NUMBER","DECIMAL","DECIMAL"),
    NUMBER1("NUMBER_BIGINT","BIGINT","BIGINT"),
    NUMBER2("NUMBER_INT","INT","INT"),
    DATE("DATE","DATE","DATE"),
    TIMESTAMP("TIMESTAMP","TIMESTAMP","TIMESTAMP"),
    CHAR("CHAR","CHAR","CHAR"),
    NCHAR("NCHAR","CHAR","CHAR"),
    SMALLINT("SMALLINT","SMALLINT","SMALLINT"),
    BINARY_FLOAT("BINARY_FLOAT","FLOAT","FLOAT"),
    FLOAT("FLOAT","FLOAT","FLOAT"),
    BINARY_DOUBLE("BINARY_DOUBLE","DOUBLE","DOUBLE PRECISION"),
    BLOB("BLOB","BLOB","TEXT"),
    BFILE("BFILE","BLOB","BLOB"),
    CLOB("CLOB","LONGTEXT","TEXT"),
    NCLOB("NCLOB","LONGTEXT","TEXT"),
    LONG("LONG","LONGTEXT","TEXT"),
    RAW("RAW","VARBINARY","BYTEA"),
    TEXT("TEXT","TEXT","TEXT");

    String oracleType;
    String mysqlType;
    String postgresType;
    OracleColumnType(String oracleType, String mysqlType, String postgresType) {
        this.oracleType = oracleType;
        this.mysqlType = mysqlType;
        this.postgresType = postgresType;
    }

    public String oracleType() {
        return oracleType;
    }


    public static String getMsqlTypeByOracleType(String  oracleType){
        for (OracleColumnType sourceEnum : OracleColumnType.values()){
            if (sourceEnum.oracleType().equals(oracleType)){
                return sourceEnum.mysqlType;
            }
        }
        return null;
    }
    public static String getPostgresTypeByOracleType(String  oracleType){
        for (OracleColumnType sourceEnum : OracleColumnType.values()){
            if (sourceEnum.oracleType().equals(oracleType)){
                return sourceEnum.postgresType;
            }
        }
        return null;
    }
}
